package Java.Exception;

//异常抛出和捕抓

class OpenFileExcetion extends java.lang.Exception {

}

class CloseFileExcetion extends OpenFileExcetion {

}

public class OpenFile {
    public static int open() {
        int[] a = new int[10];
        a[10] = 10;
        return -1;
    }

    public static void readFile() throws OpenFileExcetion, CloseFileExcetion {
        if (open() == -1) {
            throw new CloseFileExcetion();
        }
    }

    public static void main(String[] args) {


        try {
            readFile();
        } catch (CloseFileExcetion e) {
            e.printStackTrace();
            System.out.println("close");
        } catch (OpenFileExcetion e) {
            e.printStackTrace();
            System.out.println("open");
        } catch (NullPointerException e) {
            e.printStackTrace();
        } catch (java.lang.Exception e) {
            e.printStackTrace();
            System.out.println("anything");
        }


    }
}
